//---------------------------------------------------------------------------------
// Copyright (c) 2008 David Vescovi.  All rights reserved.
//
// Example AudiostixII interface
// Controls analog and digital I/O on UCB1400 Codec chip
//
//---------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Gumstix.AudioStix;

namespace test
{
    public partial class Form1 : Form
    {
        IO audio;

        public Form1()
        {
            UInt16 readback;

            InitializeComponent();
            audio = new IO();
            audio.SetGPIODirection(IO.GPIO.GPIO_0,IO.InOut.Output);
            readback = audio.GetGPIODirection();
        }

        private void btAD1_Click(object sender, EventArgs e)
        {
            UInt16 result;
            audio.SetAdChannel(IO.ADChannel.AD1);
            result = audio.ConvertAd();
            lblAD1.Text = result.ToString();
        }

        private void btIO0Off_Click(object sender, EventArgs e)
        {
            audio.BitClear(IO.GPIO.GPIO_0);
        }

        private void btIO0On_Click(object sender, EventArgs e)
        {
            audio.BitSet(IO.GPIO.GPIO_0);
        }

        private void btReadIO9_Click(object sender, EventArgs e)
        {
            if (audio.BitTest(IO.GPIO.GPIO_9))
                lblReadIO9.Text = "On";
            else
                lblReadIO9.Text = "Off";
        }

    }
}